package com.project.frba.bi.extraction.database;

import org.springframework.context.ApplicationContext;

import com.project.frba.bi.BiUtil;
import com.project.frba.bi.descriptor.Descriptor;
import com.project.frba.bi.extraction.Extractor;
import com.project.frba.bi.extraction.TransformationResultExtractor;
import com.project.frba.bi.queueing.OltpDAO;
import com.project.frba.bi.transformation.TransformationResult;

public class DatabaseExtractor implements Extractor {
	
	private String query;
	private Descriptor descriptor;
	
	public DatabaseExtractor(String query, Descriptor descriptor) {
		this.query = query;
		this.descriptor = descriptor;
	}
	
	public TransformationResult getResult(){
		ApplicationContext context = BiUtil.getApplicationContext();
		OltpDAO dao = (OltpDAO)context.getBean("oltpDAO");
		TransformationResultExtractor extractor = new TransformationResultExtractor(descriptor);
		return dao.getExtractionResult(query, extractor);
	}

}
